/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.vsked.test;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.URL;
import java.net.URLConnection;

/**
 *
 * @author Administrator
 */
public class HttpUtil {
    public static String sendPost(String urls,String param){
        StringBuffer sb=new StringBuffer();
        try{
            URL url = new URL(urls);
            URLConnection connection = url.openConnection();
            connection.setDoOutput(true);
            connection.setUseCaches(false);
            connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
            connection.connect();
            OutputStreamWriter outer = new OutputStreamWriter(connection.getOutputStream(),"UTF-8");
            outer.write(param);
            outer.flush();
            outer.close();
            BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream(),"UTF-8"));
            String inlin="";            
            while ((inlin = in.readLine()) != null) {
                sb.append(inlin);
            }
            in.close();            
        }catch(Exception e){
            e.printStackTrace();
        }
        return sb.toString();
    }
    
    
}
